package jmx;

import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
import java.lang.management.ManagementFactory;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * -Dcom.sun.management.jmxremote.port=8288 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.201.227
 * Created by sunyuming on 19/1/25.
 */
public class HelloAgent {
    public static void main(String[] args) throws Exception {

        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName objectName = new ObjectName("jmxBean:name=hello");
        server.registerMBean(new Hello(), objectName);

        // 方式一，启动时指定，代码到此为止
        /**
         * -Djava.rmi.server.hostname=192.168.57.234
         * -Dcom.sun.management.jmxremote.port=8288
         * -Dcom.sun.management.jmxremote.authenticate=false
         * -Dcom.sun.management.jmxremote.ssl=false
         */
        // 放大用
        Thread.sleep(100000000);

    }
}
